﻿using MMITWeb.Infrastructure.Abstract;
using System;
using System.IO;
using System.Reflection;
using System.Web;
using System.Web.Configuration;

namespace MMITWeb.Infrastructure.Concrete
{
    public class ResourceTemplatePath : ITemplatePath
    {
        private string _path;

        public string TemplatePath
        {
            get
            {
                if (!string.IsNullOrEmpty(_path))
                    return _path;

                var path = HttpContext.Current.Server.MapPath("~");
                _path = Path.Combine(path, WebConfigurationManager.AppSettings["templatePath"]);

                return _path;

            }
        }

        //private string GetAssemblyDirectory()
        //{
        //    //var codeBase = Assembly.GetExecutingAssembly().CodeBase;
        //     var codeBase = System.Web.Hosting.HostingEnvironment.ApplicationVirtualPath;
        //    //var uri = new UriBuilder(codeBase);
        //    //var dir = new DirectoryInfo(Uri.UnescapeDataString(uri.Path));
        //    //return dir.Parent.FullName;

        //     return string.Format("~{0}", codeBase);
        //}
    }
}